#include "cCUIImage.h"


cCUIImage::cCUIImage(const char* filename)
{
	ilGenImages(1, &texid);
	ilBindImage(texid);
	ilLoadImage((wchar_t*)filename);
	width = ilGetInteger(IL_IMAGE_WIDTH);
	height = ilGetInteger(IL_IMAGE_HEIGHT);
	texdata = new ILubyte[width*height*3];
	ilCopyPixels(0, 0, 0, width, height, 1, IL_RGB, 
		IL_UNSIGNED_BYTE, texdata);

	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
	glPixelStorei(GL_PACK_ALIGNMENT, 1);
	glGenTextures(1, &GLid);
	glBindTexture(GL_TEXTURE_2D, GLid);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, texdata);
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);

	printf("cGUIImage: Loaded image %s\n", filename);
}


cCUIImage::~cCUIImage(void)
{
}
